﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ArrayAscendingSort
{
    class Program
    {
        /// <summary>
        /// 输入10个实数，存入一个数组，用冒泡法对这个数作升序排序。
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            double[] array = new double[10];
            Console.WriteLine("请输入十个实数");
            for (int i = 0; i < 10; i++)
            {
                array[i] = Convert.ToDouble(Console.ReadLine());
            }

            Console.Write("数组排序前的结果为：");
            foreach (double n in array)
            {
                Console.Write("{0}", n + " ");
            }
            Console.WriteLine();
            for (int i = 0; i < array.Length; i++)
            {
                for (int j = i; j < array.Length; j++)
                {
                    if (array[i] > array[j])
                    {
                        double temp = array[i];
                        array[i] = array[j];
                        array[j] = temp;
                    }
                }
            }
            Console.Write("数组排序后的结果为：");
            foreach (double n in array)
            {
                Console.Write("{0}", n + " ");
            }
            Console.ReadKey();
        }
    }
}
